<?php


namespace App\Model\data;

use App\Model\FlyShop;
use Hyperf\Utils\Context;
use Psr\Http\Message\ServerRequestInterface;

class CurrentShopData
{
    /**
     * 设置商城
     * @param int $warehouseId
     * @return ServerRequestInterface
     */
    public static function setData(FlyShop $flyShop): ServerRequestInterface
    {
        $request = Context::get(ServerRequestInterface::class);
        $request = $request->withAttribute('current_shop', $flyShop);
        Context::set(ServerRequestInterface::class, $request);
        return $request;
    }


    /**
     * 获取进入之后的仓库id
     * @return int
     */
    public static function getData(): ?FlyShop
    {
        return Context::get(ServerRequestInterface::class)->getAttribute("current_shop");
    }

}